<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>制定生产计划</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
		<link rel="stylesheet" href="../../css/public.css" media="all">
		<style>
			.layui-layer-page {
			padding: 10px !important;
		}
	</style>
	</head>

	<body>
		<div class="layuimini-container">
			<div class="layuimini-main">
				<!--搜索开始-->
				<fieldset class="layui-elem-field layuimini-search">
					<legend>搜索信息</legend>
					<div style="margin: 10px 10px 10px 10px">
						<form class="layui-form layui-form-pane" action="" id="searchFrm">
							<div class="layui-form-item">
								<!-- <div class="layui-inline">
									<label class="layui-form-label">查询时间</label>
									<div class="layui-input-inline">
										<div class="layui-input-inline">
											<input type="text" name="registerTime" id="register_time" readonly="readonly" autocomplete="off" class="layui-input">
										</div>
									</div>
								</div> -->
								<div class="layui-inline">
									<label class="layui-form-label">产品名称</label>
									<div class="layui-input-inline">
										<div class="layui-input-inline">
											<input type="text" name="product_name" id="product_name" class="layui-input">
										</div>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">商品类型</label>
									<div class="layui-input-inline">
										<select name="first_kind_id">
											<option value="">商品类型</option>
											<option value="01">电子</option>
											<option value="02">机械</option>
										</select>
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block" style="text-align: center;">
									<a class="layui-btn " lay-submit="" lay-filter="data-search-btn"><label class="layui-icon layui-icon-search"></label>搜索</a>
									<a class="layui-btn layui-btn-warm" onclick="javascript:$('#searchFrm')[0].reset()" lay-filter="data-search-btn"><label
										 class="layui-icon layui-icon-refresh"></label>重置</a>
								</div>
							</div>
						</form>
					</div>
				</fieldset>
				<!--搜索结束-->

				<!--表格开始-->
				<table class="layui-hide" id="FileTable" lay-filter="FileTable"></table>
				<!-- <div style="display: none;" id="FileToolBar">
					<a class="layui-btn layui-btn-sm inport_btn_add" lay-event="add">添加</a>
				</div> -->
				<div style="display: none;" id="FileTableBar">
					<a class="layui-btn layui-btn-xs layui-btn-warm data-count-see inport_btn_see" lay-event="see">查看详情信息</a>
					<a class="layui-btn layui-btn-xs layui-btn-green data-count-add inport_btn_add" lay-event="add">制定生产计划</a>
					<!-- <a class="layui-btn layui-btn-xs layui-btn-warm data-count-delete inport_btn_update" lay-event="update">修改</a>
					<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete inport_btn_delete" lay-event="delete">删除</a>
					<a class="layui-btn layui-btn-xs layui-btn-warm data-count-delete inport_btn_back" lay-event="back">退货</a> -->
				</div>
				
				<!--表格结束-->
				<div id="MakeFile" style="display: none;padding: 0.3125rem;">
					<form method="post" class="layui-form layui-form-pane" lay-filter="FileByIddata" id="FileByIddata">
						<table  style="margin-bottom: 50px;">
							<thead>
								<tr>
									<td style="text-align: center;">编号</td>
									<td style="text-align: center;">产品名称</td>
									<td style="text-align: center;">描述</td>
									<td style="text-align: center;">用途类型</td>
									<td style="text-align: center;">数量</td>
									<td style="text-align: center;">单位</td>
									<td style="text-align: center;">生产单价</td>
									<td style="text-align: center;">小计</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="productId" id="productId" lay-verify="required|productId" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="productName" id="productName" lay-verify="required|productName" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="productDescribe" id="productDescribe" lay-verify="required|productDescribe" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="type" id="type" lay-verify="required|type" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input oninput="onAmount()" style="text-align: center;color:#C24F4A;" type="text" name="amount" id="amount" lay-verify="required|amount" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="personalUnit" id="personalUnit" lay-verify="required|personalUnit" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="realCostPrice" id="realCostPrice" lay-verify="required|realCostPrice" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td>
										<div class="layui-input-inline">
											<input onfocus=this.blur() style="text-align: center;" type="text" name="costPriceTotal" id="costPriceTotal" lay-verify="required|costPriceTotal" autocomplete="off" class="layui-input">
										</div>
									</td>
								</tr>
							</tbody>
						</table>
						<div class="layui-form-item">
							<label class="layui-form-label">备注:</label>
							<div class="layui-input-inline">
								<input style="text-align: center;" type="hidden" name="applyId" id="applyId">
								<input type="text" name="remark" id="remark" lay-verify="required|remark" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">设计人:</label>
							<div class="layui-input-inline">
								<input type="text" name="designer" id="designer" lay-verify="required|designer" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">登记人:</label>
							<div class="layui-input-inline">
								<input type="text" name="register" id="register" lay-verify="required|register" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">复合意见:</label>
							<div class="layui-input-inline">
								<input type="text" name="check_suggestion" placeholder="给审核人的意见" id="check_suggestion" lay-verify="required|check_suggestion" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="" style="text-align: center;">
								<a class="layui-btn layui-btn-green" lay-submit="" lay-filter="makePlan"><label class="layui-icon layui-icon-release"></label>制定</a>
							<!-- 	<a class="layui-btn layui-btn-sm layui-btn-warm" onclick="javascript:$('#plandata')[0].reset()" lay-filter="data-search-btn"><label
									 class="layui-icon layui-icon-refresh"></label>重置</a> -->
								<a class="layui-btn layui-btn-warm" onclick="javascript:layer.close(mainIndex)">
									<label class="layui-icon layui-icon-close"></label>关闭
								</a>
							</div>
						</div>
					</form>
				</div>
				
				<!-- 详情数据 -->
				<div id="SeeFile" style="display: none;padding: 0.3125rem;">
					<form method="post" class="layui-form layui-form-pane" lay-filter="Filedata" id="Filedata">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">产品名称:</label>
								<div class="layui-input-inline">
									<input type="text" name="productName" id="productName" lay-verify="required|applyId" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">制造商:</label>
								<div class="layui-input-inline">
									<input type="text" name="factoryName" lay-verify="required|factoryName" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">产品简介:</label>
								<div class="layui-input-inline">
									<input type="text" name="productNick" id="productNick" lay-verify="required|productName" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">一级分类:</label>
								<div class="layui-input-inline">
									<input type="text" name="firstKindName" id="firstKindName" lay-verify="required|firstKindName" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">二级分类:</label>
								<div class="layui-input-inline">
									<input type="text" name="secondKindName" lay-verify="required|secondKindName" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">三级分类:</label>
								<div class="layui-input-inline">
									<input type="text" name="thirdKindName" id="thirdKindName" lay-verify="required|costPriceTotal" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">市场单价:</label>
								<div class="layui-input-inline">
									<input type="text" name="listPrice" id="listPrice" lay-verify="required|listPrice" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">计划成本单价:</label>
								<div class="layui-input-inline">
									<input type="text"  name="costPrice" lay-verify="required|costPrice" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">计量单位:</label>
								<div class="layui-input-inline">
									<input type="text" name="personalUnit" id="personalUnit" lay-verify="required|personalUnit" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">计量值:</label>
								<div class="layui-input-inline">
									<input type="text" name="personalValue" id="personalValue" lay-verify="required|personalValue" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">保修期:</label>
								<div class="layui-input-inline">
									<input type="text" name="warranty" lay-verify="required|warranty" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">库存分配标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="designCellTag" id="designCellTag" lay-verify="required|designCellTag" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">替代品名称:</label>
								<div class="layui-input-inline">
									<input type="text" name="twinName" id="twinName" lay-verify="required|twinName" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">替代品编号:</label>
								<div class="layui-input-inline">
									<input type="text" name="twinId" lay-verify="required|twinId" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">生命周期:</label>
								<div class="layui-input-inline">
									<input type="text" name="lifecycle" id="lifecycle" lay-verify="required|productDescribe" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">用途类型:</label>
								<div class="layui-input-inline">
									<input type="text" name="type" id="type" lay-verify="required|type" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">档次级别:</label>
								<div class="layui-input-inline">
									<input type="text" name="productClass" lay-verify="required|productClass" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">产品经理:</label>
								<div class="layui-input-inline">
									<input type="text" name="responsiblePerson" lay-verify="required|responsiblePerson" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">登记人:</label>
								<div class="layui-input-inline">
									<input type="text" name="register" id="register" lay-verify="required|register" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">建档时间:</label>
								<div class="layui-input-inline">
									<input type="text" name="registerTime" lay-verify="required|registerTime" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">复核人:</label>
								<div class="layui-input-inline">
									<input type="text" name="checker" lay-verify="required|checker" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">复核时间:</label>
								<div class="layui-input-inline">
									<input type="text" name="checkTime" id="checkTime" lay-verify="required|checkTime" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">审核标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="checkTag" lay-verify="required|checkTag" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">变更人:</label>
								<div class="layui-input-inline">
									<input type="text" name="changer" lay-verify="required|changer" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">变更时间:</label>
								<div class="layui-input-inline">
									<input type="text" name="changeTime" id="changeTime" lay-verify="required|changeTime" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">档案变更标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="changeTag" lay-verify="required|changeTag" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">价格变更标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="priceChangeTag" lay-verify="required|priceChangeTag" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">档案变更累计:</label>
								<div class="layui-input-inline">
									<input type="text" name="fileChangeAmount" id="fileChangeAmount" lay-verify="required|fileChangeAmount" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">工序组成标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="designProcedureTag" lay-verify="required|designProcedureTag" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">物料组成标志:</label>
								<div class="layui-input-inline">
									<input type="text" name="designModuleTag" lay-verify="required|designModuleTag" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">产品描述:</label>
								<div class="layui-input-inline">
									<input type="text" name="productDescribe" id="productDescribe" lay-verify="required|productDescribe" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">供应商集合:</label>
								<div class="layui-input-inline">
									<input type="text" name="providerGroup" lay-verify="required|providerGroup" autocomplete="off" class="layui-input">
								</div>
							</div>
						</div>
						
						<!-- <div class="layui-form-item">
							<label class="layui-form-label">支付类型</label>
							<div class="layui-input-block">
								<input type="radio" name="paytype" value="支付宝" title="支付宝" checked="">
								<input type="radio" name="paytype" value="微信" title="微信">
								<input type="radio" name="paytype" value="银联" title="银联">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">备注</label>
							<div class="layui-input-block">
								<textarea placeholder="请输入备注" name="remark" class="layui-textarea"></textarea>
							</div>
						</div> -->
						<div class="layui-form-item">
							<div class="" style="text-align: center;">
								<!-- <a class="layui-btn layui-btn-sm" lay-submit="" lay-filter="doSubmit"><label class="layui-icon layui-icon-release"></label>提交</a>
								<a class="layui-btn layui-btn-sm layui-btn-warm" onclick="javascript:$('#plandata')[0].reset()" lay-filter="data-search-btn"><label
									 class="layui-icon layui-icon-refresh"></label>重置</a> -->
								<a class="layui-btn layui-btn-sm layui-btn-warm" onclick="javascript:layer.close(mainIndex)">
									<label class="layui-icon layui-icon-close"></label>关闭   
								</a>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
		<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
		<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
		<script src="../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
		<script src="../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
		<script src="../../lib/common/common.js" charset="utf-8"></script>

		<script>
			function onAmount() {
							var amount=$("#amount").val();
							var productId=$("#productId").val();
							// var params="amount="+amount;
							
							// $.post(api + "outport/addOutport", params, function(res) {
							
							$.get(api + "liuxinyu/file/selMaterialAmount?productId="+productId+"&amount="+amount, function(res){
								if(res.codeback==100){
									console.log(res);
									layer.msg(res.msg);
									$("#zhiding").css("visibility","visible");
								}else{
									console.log(res);
									layer.msg(res.msg);
									$("#zhiding").css("visibility","hidden");
								}
							});
							var realCostPrice=$("#realCostPrice").val();
							var costPriceTotal=realCostPrice*amount;
							$("#costPriceTotal").val(costPriceTotal);
						}
			
			// designer
			
			//监听单元格编辑
			// form.on('edit(data-amount-btn)', function(obj) {
			
			// 	/* var value = obj.value //得到修改后的值
			// 		,
			// 		data = obj.data //得到所在行所有键值
			// 		,
			// 		field = obj.field; //得到字段
			// 	// console.log(value, data, field)
			// 	layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为：' + value); */
			// 	//	// console.log("监听单元格数据",obj.tr[0].childNodes[9].childNodes[0].innerHTML = (obj.value * obj.data.costPrice));
			// 	alret(obj.value);
			// 	sum += (obj.value * obj.data.realCostPrice);
			// 	// console.log("监听单元格数据", )
			// 	console.log(sum)
			
			// 	let data = obj.data;
			// 	// console.log(data)
			
			// 	if (data.bgamount > data.residualAmount) {
			// 		layer.msg('可用数量超出，请重新输入');
			// 		obj.tr[0].childNodes[8].childNodes[0].innerHTML = data.residualAmount
			// 		// data.bgamount = data.residualAmount;
			// 		// obj.value = 0;
			// 	} else {
			// 		if (data !== undefined) {
			// 			// console.log(data);
			// 			let residualAmount;
			// 			if (data.bgamount !== ' ' || data.bgamount !== null) {
			// 				console.log("里面", data.bgamount)
			// 				residualAmount = (parseInt(data.residualAmount) - parseInt(data.bgamount));
			// 				data.residualAmount = residualAmount;
			// 				if (residualAmount !== NaN || data.bgamount !== '') {
			// 					obj.tr[0].childNodes[5].childNodes[0].innerHTML = data.residualAmount;
			// 				}
			// 			}
			// 			submitData.push(data);
			// 		}
			// 		layer.msg('[ID: ' + data.productName + '] 工序数量使用量：' + data.bgamount + "可用数量:" + data.residualAmount);
			// 	}
			
			// });
		</script>
		<script>
			layui.use(['form', 'table', 'laydate', 'layer'], function() {
				var form = layui.form;
				var table = layui.table;
				var laydate = layui.laydate;
				var layer = layui.layer;

				//渲染时间选择器
				laydate.render({
					elem: '#register_time',
					type: 'datetime'
				});
				// laydate.render({
				// 	elem: '#endTime',
				// 	type: 'datetime'
				// });

				// //加载查询条件里面的供应商的下拉列表
				// $.get(api6 + "provider/getAllAvailableProvider", function(res) {
				// 	var search_providerid = $(".providerSel");
				// 	var html = "<option value =''>请选择供应商</option>";
				// 	var data = res.data;
				// 	$.each(data, function(index, item) {
				// 		// 注入供应商ID 和 名称
				// 		html += "<option value =" + item.id + ">" + item.providername + "</option>"
				// 	});
				// 	search_providerid.html(html);
				// 	// 重载下拉框
				// 	form.render("select");
				// });


				// //加载查询条件里面的商品的下拉列表
				// $.get(api6 + "goods/getAllAvailableGoods", function(res) {
				// 	var search_goodsid = $(".goodsSel");
				// 	var html = "<option value =''>请选择商品</option>";
				// 	var data = res.data;
				// 	$.each(data, function(index, item) {
				// 		// 注入商品ID 和 名称
				// 		html += "<option value =" + item.id + ">" + item.goodsname + "--[" + item.size + "]" + "</option>"
				// 	});
				// 	search_goodsid.html(html);
				// 	// 重载下拉框
				// 	form.render("select");
				// });

				var tableIns = table.render({
					elem: '#FileTable',
					url: api6 + 'file/selAllFile',
					toolbar: "#FileTable",
					cellMinWidth: true,
					
					cols: [
						[{
								field: 'productId',
								title: '编号',
								align: "center",
								width: 150
							},
							{
								field: 'productName',
								title: '产品名称',
								align: "center",
								width: 150
							},
							{
								field: 'firstKindName',
								title: '商品类型',
								align: "center",
								width: 133
							},
							{
								field: 'listPrice',
								title: '市场单价',
								align: "center",
								width: 130
							},
							{
								field: 'costPrice',
								title: '计划成本单价',
								align: "center",
								width: 130
							},
							{
								field: 'realCostPrice',
								title: '实际成本单价',
								align: "center",
								width: 140
							},
							{
								field: 'productClass',
								title: '档次级别',
								align: "center",
								width: 150,
								templet:"#TproductClass"
							},
							{
								field: 'register',
								title: '创建人',
								align: "center",
								width: 150
							},
							{
								field: 'registerTime',
								title: '添加时间',
								align: "center",
								width: 250
							},
							{
								title: '操作',
								templet: '#FileTableBar',
								fixed: "right",
								align: "center",
								width: 250
							}
						]
					],
					page: true
				});
				

				// 查看详情
				function MakeFile(data) {
					var designId='301';
					var time=new Date();
					var year= time.getFullYear();
					designId+=year
					var month= time.getMonth()+1
					if(month>=0){
					month='0'+month
					}
					designId+=month
					var date=time.getDate();
					designId+=date
					console.log(designId)
					mainIndex = layer.open({
						type: 1,
						title: '制定生产计划',
						content: $("#MakeFile"),
						area: ['1200px', '407px'],
						success: function(index) {
				
				
							// layer.tips('需要修改进货数量直接覆盖数量即可', '#numbers', {
							// 	tips: 1
							// });
				
							$.get(api6 + "file/selByIdFile?id="+data, function(res) {
									if(res.type= "Y001-1"){
										res.type= "商品";
									}else{
										res.type= "物料";
									}
									console.log(res);
									$("#applyId").val(designId);
									$("#designer").val(username);
									form.val("FileByIddata", res);
									// window.alert(res.product_name);
								// layer.close(mainIndex);
							})
							form.render();
						}
					});
				}
				close
				
				
				// 查看详情
				function SeeFile(data) {
					mainIndex = layer.open({
						type: 1,
						title: '查看详情信息',
						content: $("#SeeFile"),
						area: ['1000px', '607px'],
						success: function(index) {
				
				
							// layer.tips('需要修改进货数量直接覆盖数量即可', '#numbers', {
							// 	tips: 1
							// });
				
							$.get(api6 + "file/selByIdFile?id="+data, function(res) {
									console.log(res);
									//审核
									if(res.checkTag= "S001-1"){
										res.checkTag= "等待审核";
									}else if(res.checkTag= "S001-2"){
										res.checkTag= "审核通过";
									}else{
										res.checkTag= "审核不通过";
									}
									//库存分配
									if(res.designCellTag= "K001-1"){
										res.designCellTag= "未设计";
									}else{
										res.designCellTag= "已设计";
									}
									//用途类型
									if(res.type= "Y001-1"){
										res.type= "商品";
									}else{
										res.type= "物料";
									}
									//档次级别
									if(res.productClass= "D001-1"){
										res.productClass= "高档";
									}else if(res.checkTag= "D001-2"){
										res.productClass= "中档";
									}else{
										res.productClass= "低档";
									}
									//档案变更标志
									if(res.changeTag= "D002-1"){
										res.changeTag= "未变更";
									}else{
										res.changeTag= "已变更";
									}
									//价格变更标志
									if(res.priceChangeTag= "J001-1"){
										res.priceChangeTag= "未变更";
									}else{
										res.priceChangeTag= "已变更";
									}
									//工序组成标志
									if(res.designProcedureTag= "G001-1"){
										res.designProcedureTag= "未设计";
									}else{
										res.designProcedureTag= "已设计";
									}
									//物料组成标志
									if(res.designModuleTag= "W001-1"){
										res.designModuleTag= "未设计";
									}else{
										res.designModuleTag= "已设计";
									}
									form.val("Filedata", res);
									// window.alert(res.product_name);
								// layer.close(mainIndex);
							})
							// var providerid = data.providerid;
							// var goodsDataSel = $(".goodsDataSel");
							// 调用初始化下拉框 
							// initGoodsSeleted(providerid, goodsDataSel, function() {
								//装载数据表格
								
							// });
							// 禁用下拉框  
							// $("#data_providerid").attr("disabled", true);
							// $("#data_goodsid").attr("disabled", true);
							form.render();
						}
					});
				}

				// 监听搜索操作
				form.on('submit(data-search-btn)', function(data) {
					var params = $("#searchFrm").serialize();
					console.log(params);
					//执行搜索重载
					table.reload('FileTable', {
						page: {
							curr: 1
						},
						url: api6 + 'file/selAllFile?' + params
					});
					return false;
				});

				// //监听表头的事件
				// table.on('toolbar(FileTable)', function(obj) {
				// 	var checkStatus = table.checkStatus(obj.config.id);
				// 	switch (obj.event) {
				// 		case 'add':
				// 			openAddInport();
				// 			break;
				// 	};
				// });
				
				
				//提交数据
				form.on("submit(makePlan)", function(data) {
					var params = $("#FileByIddata").serialize();
					$.post(api6+"plan/addPlan", params, function(res) {
						layer.msg(res.msg);
						if (res.code == 200) {
							tableIns.reload();
						}
						layer.close(mainIndex);
					})
					return false;
				});

				//监听添加弹出层里面的 供应商   的下拉改变事件
				form.on("select(data_providerid)", function(obj) {
					// 获取供应商ID
					var providerid = obj.value;
					// 获取商品下拉框
					var goodsDataSel = $(".goodsDataSel");
					initGoodsSeleted(providerid, goodsDataSel)
				})


				//监听行数据的事件
				table.on('tool(FileTable)', function(obj) {
					var data = obj.data;
					if (obj.event === 'delete') {
						layer.confirm('真的删除这条进货数据么', function(index) {
							$.post(api6 + "inport/deleteInport", {
								id: data.id
							}, function(res) {
								layer.msg(res.msg);
								obj.del();
								layer.close(index);
							})
						});
					} else if (obj.event === 'update') {
						openUpdateInport(data);
					} else if (obj.event === 'back') {
						openBack(data);
					}else if (obj.event === 'see') {
						SeeFile(data.id);
					}else if (obj.event === 'add') {
						MakeFile(data.id);
					}
				});

				
				// form.on("submit(close)", function(data) {
				// 	// 序列化
				// // 	var params = $("#backDataFrm").serialize();
				
				// // 	$.post(api6 + "outport/addOutport", params, function(res) {
				// // 		layer.msg(res.msg);
				// // 		if (res.code == 200) {
				// // 			tableIns.reload();
				// // 		}
				// 		layer.close(mainIndex);
				// // 	})
				// // 	return false;
				// });
				
			});
		</script>
		<script type="textml" id="TproductClass">
					{{# if(d.productClass=='D001-1'){d.productClass='高档'}}
						{{d.productClass}}
					{{# }else if(d.productClass=='D001-2'){d.productClass='中档'}}
						{{d.productClass}}
					{{# }else{d.productClass='抵挡'}}
						{{d.productClass}}
					{{# }}}
		</script>

	</body>

</html>
